package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1185 {
    public long startExecuteTime = System.currentTimeMillis();

    /*
     * @param 此题目参考了别人代码，自己只理解思想
     * @return:
     * 著名的蔡勒公式，初中就学习过，青涩啊！
     */
    class Solution {

        public String[] dayList = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

        public String dayOfTheWeek(int day, int month, int year) {
            int c, y, week;
            if (month == 1 || month == 2) {
                year--;
                month += 12;
            }

            c = year / 100;
            y = year - c * 100;
            week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1;
            while (week < 0)
                week += 7;
            week %= 7;
            return dayList[week];
        }
    }

    public void run() {
        Solution solution = new Solution();
        System.out.println(solution.dayOfTheWeek(31, 8, 2019));
        System.out.println(solution.dayOfTheWeek(18, 7, 1999));
    }

    public static void main(String[] args) throws Exception {
        LC1185 an = new LC1185();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
